{extend name="base" /} {block name="body"}
<div class="layui-body">
	<!--tab标签-->
	<div class="layui-tab layui-tab-brief">
		<ul class="layui-tab-title">
			<li class="">
				<a href="{:url('agent/index')}">商家管理</a>
			</li>
			<li class="layui-this">编辑商家</li>
		</ul>
		<div class="layui-tab-content">
			<div class="layui-tab-item layui-show">
				<form class="layui-form form-container" action="{:url('agent/update')}" method="post">
					<div class="layui-form-item">
						<label class="layui-form-label">商家名称</label>
						<div class="layui-input-block">
							<input type="text" name="agent_name" value="{$agent.agent_name}" required lay-verify="required" placeholder="请输入商家名称" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">商家logo</label>
						<div class="layui-input-block" style="padding-left: 10px;">
							<div class="layui-upload">
								<button type="button" class="layui-btn" id="image">上传图片</button>
								<div class="layui-upload-list">
									<img class="layui-upload-img" src="{$agent.thumb}" style="width: 150px;height: 150px;" id="demo1">
									<p id="demoText"></p>
								</div>
							</div>
						</div>
						<input type="hidden" name="thumb" id="thumb" value="{$agent.thumb}"/>
					</div>
					
					<div class="layui-form-item">
						<label class="layui-form-label">手机号码</label>
						<div class="layui-input-block">
							<input type="text" name="mobile" value="{$agent.mobile}"  placeholder="请输入账号(手机号)" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
					    <label class="layui-form-label">请选择分类</label>
					    <div class="layui-input-block">
					      <select name="goodstype" required lay-verify="required" lay-filter="aihao" class="layui-input">
					        <option value=""></option>
							{volist name="type_list" id="vo"}
							<option value="{$vo.id}" {if condition="$agent.goodstype==$vo.id" } selected="selected" {/if}>{$vo.name}</option>
							{/volist}
					      </select>
					    </div>
				  	</div>
					<div class="layui-form-item">
						<label class="layui-form-label">商家地址</label>
						<div class="layui-input-inline" style="width: 640px;">
							<input type="text" id="address" name="address" value="{$agent.address}" placeholder="请输入商家地址" class="layui-input">
						</div>
						<div class="layui-form-mid layui-word-aux"><a href="#" onclick="show_map({$agent.id})">修改</a></div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">经度</label>
						<div class="layui-input-inline" style="width: 640px;">
							<input type="text" id="longitude" name="longitude" value="{$agent.longitude}" placeholder="" class="layui-input">
						</div>
						
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">纬度</label>
						<div class="layui-input-inline" style="width: 640px;">
							<input type="text" id="latitude" name="latitude" value="{$agent.latitude}" placeholder="" class="layui-input">
						</div>
						
					</div>
					<div class="layui-form-item" >
						<label class="layui-form-label">操作密码</label>
							<div class="layui-input-block">
							<input type="text" name="password" value="{$agent.password}" placeholder="请输入操作密码" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">活动简介</label>
						<div class="layui-input-block">
							<textarea name="activity" placeholder="请输入商家活动" class="layui-textarea">{$agent.activity}</textarea>
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">状态</label>
						<div class="layui-input-block">
							<input type="radio" name="status" value="1" title="显示" {if condition="$agent.status==1" } checked="checked" {/if}>
							<input type="radio" name="status" value="2" title="不显示" {if condition="$agent.status==2" } checked="checked" {/if}>
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">排序</label>
						<div class="layui-input-block">
							<input type="text" name="sort" value="{$agent.sort}" placeholder="请输入序号" class="layui-input">
						</div>
					</div>

					<div class="layui-form-item" >
						<label class="layui-form-label">商家介绍</label>
						<div class="layui-input-block" style="z-index: 1">
							<script style="width:960px;height:600px" id="content" name="content" type="text/plain">
								{if isset($agent.content)}{$agent.content|html_entity_decode}{/if}
							</script>
						</div>
					</div>
					<div class="layui-form-item">
						<div class="layui-input-block">
							<input type="hidden" name="id" value="{$agent.id}">
							<button class="layui-btn" lay-submit lay-filter="*">更新</button>
							<button type="reset" class="layui-btn layui-btn-primary">重置</button>
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>
</div>
{/block}
{block name="js"}
<script type="text/javascript" src="/public/static/js/image.zip.js"></script>
<script type="text/javascript" src="/public/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="/public/ueditor/ueditor.all.js"></script>

<script>
	var ue = UE.getEditor('content', {
        initialFrameHeight: 450,
		serverUrl: "{:url('admin/ueditor/index?cate=news')}"
	});
	var GV = {
		current_controller: "agent/index"
	};
		layui.use('upload', function() {
		var upload = layui.upload,
		jq = layui.jquery;
		upload.render({
			url: '{:url("upload")}',
			elem: '#image',
			ext: 'jpg|png|gif',
			area: ['500', '500px'],
			before: function(input) {
				
			},
			done: function(res) {
				if(res.code==1){
					$("#demo1").attr('src',res.src);
					$("#thumb").val(res.src);
				}
			}
		});
	})

	//修改地址
	function show_map() {
		var url = "{:url('edit_address')}";		
		layer.open({
			type: 2,
			title: '修改地址',
			shadeClose: true,
			shade: 0.8,
			area: ['1000px', '550px'],
			content: [url]
		});
	}
</script>
{/block}